﻿//
// Created by work on 24-6-6.
//

#ifndef IOT_PLAT_CRTMODELPARAMETERINFO_H
#define IOT_PLAT_CRTMODELPARAMETERINFO_H

#include "CRtModelSigBase.h"


class CRtModelParameterInfo : public CRtModelSigBase {
    Q_OBJECT
public:
    enum EParameterType {
        EInt,
        EString,
        Efloat
    };

    enum EModelParameterCol {
        EPtype = 0x07,
        EEn_write,
        EEn_read
    };

    EParameterType ptype;
    bool en_write;
    bool en_read;

    static std::map<CRtModelParameterInfo::EModelParameterCol, QString> rtModelParameterColToStringMap;
    static std::map<CRtModelParameterInfo::EModelParameterCol, QString> parameterColFieldsNameMap;
    static std::map<CRtModelParameterInfo::EModelParameterCol, CValue::EValueType> rtParameterDataTypeByField;
public:
    explicit CRtModelParameterInfo(QObject* parent = nullptr);

public:
    virtual QString getFieldNameByCol(int col)override;

    virtual QVariant getFieldValueByFielddName(const QString& name)override;

    virtual void setFieldValueByCol(int col, const QVariant& value)override;

    virtual QJsonObject toJson()override;

    virtual void fromJson(const QJsonObject &json)override;

    virtual QSharedPointer<IModel> createEmpty()override;

    virtual bool sync(bool dir = true) override;
};

#define PARAMETER_ENUM                     CRtModelParameterInfo::EModelParameterCol
#define parameterFieldName(type)           CRtModelParameterInfo::rtModelParameterColToStringMap.find(type)->second
#define parameterColFieldName(type)        CRtModelParameterInfo::parameterColFieldsNameMap.find(type)->second
#define PARAMETER_COL_SIZE                 (SIGBASE_COL_SIZE + rtModelParameterColToStringMap.size())


#endif //IOT_PLAT_CRTMODELPARAMETERINFO_H
